<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <!DOCTYPE html>
<html>

<head>
	<base href="/">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    

    <title>调度</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> <link href="static/templet/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="static/templet/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="static/templet/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="static/templet/css/animate.min.css" rel="stylesheet">
    <link href="static/templet/css/style.min862f.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
    <form action="task/keywords" method="post" id="taskForm">
        <div class="row">          
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                    	<a class="btn btn-primary " href="javascript:add();" target="_self">新增</a>
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>调度名称</th>
                                    <th>调度类型</th>
                                    <th>任务时间</th>
                                    <th>执行时间</th>
                                    <th>重新执行</th>
                                </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${page.list}" var="task" varStatus="vs">
                            	<tr>
                                    <td>${task.id }</td>
                                    <td>${task.taskName }</td>
                                    <td>${task.taskCode }</td>
                                    <td>${task.taskTime }</td>
                                    <td>${task.runTime }</td>
                                    <td><a class="fa fa-automobile" href="javascript:run('${task.taskTime}');" title="执行"></a>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                         <jsp:include page="/WEB-INF/jsp/page.jsp">
                        	<jsp:param value="taskForm" name="form"/>
                        </jsp:include>
                    </div>
                </div>
            </div>
        </div>
        </form>
    </div>
    <script src="static/templet/js/jquery.min.js?v=2.1.4"></script>
    <script src="static/templet/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="static/templet/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="static/templet/js/content.min.js?v=1.0.0"></script>
    <script src="static/templet/js/plugins/iCheck/icheck.min.js"></script>
    <script src="static/templet/js/demo/peity-demo.min.js"></script>
    <script src="static/templet/js/plugins/layer/layer.min.js"></script>
    <script src="static/templet/js/iframe.min.js"></script>
    <script type="text/javascript">
    function add(){
    	parent.layer.open({
    	    type: 2,
    	    title: '新增关键词扣费调度',
    	    shadeClose: true,
    	    shade: 0.8,
    	    area: ['40%', '80%'],
    	    content: 'task/keywords/add',
    	    cancel:function(index, layero){
    	    	iframe.get(layero);
    	    	if(result == 1){
    	    		location.reload(true);
    	    	}
    	    	
    	    }
    	});
    }
    
	function run(taskTime){
		parent.layer.confirm('确定重复执行吗？', {
		    btn: ['确定','取消'], //按钮
		    shade: false //不显示遮罩
		}, function(){
			var load = parent.layer.load(1, {
		        shade: [0.1,'#fff']
		    });
			if(taskTime == ''){
				parent.layer.msg('请选择执行日期', {icon: 1});
				parent.layer.close(load);
				return;
			}
			$.post('task/keywords/runKeywords',{taskTime:taskTime}, function(data, status){
				if(status == 'success'){
					var result = data.result;
					var state = result.state;
					parent.layer.close(load);
					if(state == 1){
						parent.layer.msg('保存成功', {icon: 1});
					}else{
						parent.layer.msg(result.message, {icon: 1});
					}
				}
			})
		}, function(){
		   
		});
		
		
	}

    </script>

</body>

</html>